package cn.uce.cc.rest.control;

import cn.uce.cc.api.service.biz.ICcosOrgBiz;
import cn.uce.web.common.base.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

 /**
   * 快运系统机构相关
   * @Author liupan
   * @Description
   * @Date  2020-06-30 15:43
   */
@Controller
@RequestMapping(value = "ccos/org")
public class CcosOrgController extends BaseController {

    private Logger log = LoggerFactory.getLogger(CcosOrgController.class);

    @Resource
    private ICcosOrgBiz ccosOrgBiz;



     /**
       * 提供界面用来做机构组件
       * @Author liupan
       * @Description
       * @Date  2020-06-30 15:43
       */
    @RequestMapping(value = "/getwebpointsforworkorder", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> getWebPointsForWorkOrder(String point, String page)  {
        try {
            Map<String, String> map = new HashMap<String, String>();
            map.put("keyWorkds", point);
            map.put("currentPage", page);
            return returnSuccess( ccosOrgBiz.getWebPointsForWorkOrder(map));
        } catch (Exception e) {
            log.error("CsSmsMessageController,sendPhoneMessage,Exception",e);
            returnError("查询机构失败");
        }
        return null;
    }

     /**
       * 查询机构详情
       * @Author liupan
       * @Description
       * @Date  2020-06-30 15:44
       */
    @RequestMapping(value = "/queryDetial", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> queryNetDetail(String deptCode)   {
        try {
            return returnSuccess(ccosOrgBiz.getNetDetial(deptCode));
        } catch (Exception e) {
            logger.error("查询网点详细信息出现异常：" + e);
        }
        return null;
    }


     /**
      * 查询机构
      * @param point
      * @param currentPage
      * @return
      */
     @RequestMapping(value = "/getwebpoints", method = RequestMethod.POST)
     @ResponseBody
     public Map<String, Object> getwebpoints(String point, String currentPage){
         try {
             Map<String, String> map = new HashMap<String, String>();
             map.put("keyWorkds", point);
             map.put("currentPage", currentPage);
             String result = ccosOrgBiz.getWebPoints(map);
             return returnSuccess(result);
         } catch (Exception e) {
             logger.error("路由网点模糊查询失败：" + e);
         }
         return returnError("路由网点模糊查询失败");
     }
}
